package com.kuhyygy.activity;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.kuhyygy.R;
import com.kuhyygy.async.DownloadAsyncTask;

/**
 * 异步任务应用
 * 
 * @author acer
 *
 */
public class AsyncActivity extends BaseActivity {
	
	private TextView tv ;
	private ProgressBar pb;
	private Button btn;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.asyncmain);
		tv = (TextView) this.findViewById(R.id.asyncText);
		pb = (ProgressBar) this.findViewById(R.id.asyncProgressBar);
		btn = (Button) this.findViewById(R.id.asyncBtn);
		setProgressBarIndeterminate(false);
		
		btn.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				pb.setVisibility(View.VISIBLE);
				DownloadAsyncTask dat = new DownloadAsyncTask(tv, pb);
				dat.execute(1000);
			}
		});
	}

}
